package model

import daos.VillanoDAO
import java.awt.Color
import modelApp.OrdenDeArrestoAppModel
import org.uqbar.arena.layout.HorizontalLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.windows.WindowOwner
import templates.MyOwnSimpleWindow

class OrdenDeArrestoView extends MyOwnSimpleWindow<OrdenDeArrestoAppModel>{
	
	new(WindowOwner parent, Detective detective, VillanoDAO villanos) {
		super(parent, new OrdenDeArrestoAppModel(detective, villanos.villanos))
	}
		
	override createContents(Panel mainPanel) {
		
		this.setTitle("Resolviendo: Robo del Faraón")
		mainPanel.setLayout(new VerticalLayout)
		val Panel panelSuperior = new Panel(mainPanel).setLayout(new HorizontalLayout).setWidth(120)
		
		val Panel panelMedio = new Panel(mainPanel).setLayout(new HorizontalLayout)
		val Panel panelInferior = new Panel(mainPanel).setLayout(new HorizontalLayout)
		
		new Label(panelSuperior) => [
			setText("Orden de Arresto emitida contra: ")
		]
		
		new Label(panelSuperior) => [
			bindValueToProperty("detective.ordenArresto.villanoAcusado")
		]
		
		new Label(panelMedio) => [
			setText("Villano: ")
		]
		
		new Selector(panelMedio) => [
			allowNull(false)
			bindItemsToProperty("villanos")
			bindValueToProperty("villanoAcusar")
			setWidth(210)
		]
		
		new Button(panelInferior) => [
			bindEnabledToProperty("puedeAgregar")
			setCaption("Generar Orden de Arresto")
			setBackground(Color ::LIGHT_GRAY)
			setWidth(150)
			onClick([| this.modelObject.generarOrdenDeArresto /*---> */ close])
			
		]
	}
}